//
//  assetsOrderViewController.m
//  DBAChain
//
//  Created by Mxionlly on 2018/9/7.
//  Copyright © 2018年 Evan. All rights reserved.
//

#import "assetsOrderViewController.h"
#import "DWTabView.h"
#import "CommonData.h"
#import "DWPageViewController.h"
#import "assetsOrderBuyViewController.h"
#import "assetsOrderSellViewController.h"
#import "assetsOrderTradViewController.h"
#import "assetsOrderDoneViewController.h"
#import "assetsOrderComViewController.h"

@interface assetsOrderViewController ()<BMPageViewControllerDelegate>
@property (nonatomic,strong)    DWTabView        *tabView;
@property (nonatomic,strong) UIView *pageContentView;
@end

@implementation assetsOrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"订单";
    [self initUI];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    self.hidesBottomBarWhenPushed = NO;
    self.tabBarController.tabBar.hidden = YES;
    self.navigationController.navigationBar.hidden = NO;
     [self setBlackStatus:YES];
}

- (void)initUI {
    _tabView = [[DWTabView alloc]initWithFrame:CGRectMake(0, 64, KScreenWidth, 40)];
    [self.view addSubview:_tabView];
    _pageContentView = [[UIView alloc]initWithFrame:CGRectMake(0, 104, KScreenWidth, KScreenHeight - 104)];
    [self.view addSubview:_pageContentView];
    DWPageViewController *pageVC = [[DWPageViewController alloc] initWithViewControllers:@[[assetsOrderBuyViewController new], [assetsOrderSellViewController new],[assetsOrderTradViewController new], [assetsOrderDoneViewController new],[assetsOrderComViewController new]]];
    pageVC.delegate = self;
    [self addViewController:pageVC];
    
    self.tabView.items = @[@"求购中", @"出售中", @"交易中",@"已完成",@"申诉中"];
    self.tabView.indicatorPosition = BMTabViewIndicatorPoistionBottom;
    self.tabView.selection = ^(NSUInteger index, NSUInteger oldIndex) {
        pageVC.selectIndex = (unsigned int)index;
    };
}

- (void)addViewController:(UIViewController *)pageVC
{
    [self addChildViewController:pageVC];
    [self.pageContentView addSubview:pageVC.view];
    [pageVC didMoveToParentViewController:self];
}

- (void)pageViewController:(DWPageViewController *)pageViewController didScrollToIndex:(int)index
{
    self.tabView.selectedIndex = index;
}

- (void)pageViewController:(DWPageViewController *)pageViewController didScrollBetweenIndex1:(int)index1 index2:(int)index2 withPercent:(CGFloat)percent
{
    [self.tabView scrollIndicatorBetweenIndex1:index1 index2:index2 withPercent:percent];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
